#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

struct ListNode {
    int val;
    ListNode* next;
    ListNode(int x) : val(x), next(NULL) {}
};

class Node {
   public:
    int val;
    Node* next;
    Node* random;

    Node(int _val) {
        val = _val;
        next = NULL;
        random = NULL;
    }
};

struct TreeNode {
    int val;
    TreeNode* left;
    TreeNode* right;
    TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};

class Solution {
   public:
    ListNode* getIntersectionNode(ListNode* headA, ListNode* headB) {
        int a_length = 0, b_length = 0;
        ListNode *a_tmp = headA, *b_tmp = headB;
        while (a_tmp) {
            a_length++;
            a_tmp = a_tmp->next;
        }
        while (b_tmp) {
            b_length++;
            b_tmp = b_tmp->next;
        }
        while (a_length > b_length) {
            a_length--;
            headA = headA->next;
        }
        while (b_length > a_length) {
            b_length--;
            headB = headB->next;
        }
        while (headA && headB && headA != headB) {
            headA = headA->next;
            headB = headB->next;
        }
        return headA;
    }
};

int main() {
    cout << "Hello, World!";
    // Solution()
    return 0;
}
